import QtQuick 2.0

Rectangle {
    width: 800
    height: 600

    id: player_widget

    MouseArea {
        id: player_mouse_area
        acceptedButtons: Qt.LeftButton | Qt.RightButton
        anchors.fill: parent
        onDoubleClicked: console.log("double click")
        onPressed: {
            console.log("someting pressed")
            if (mouse.button == Qt.RightButton) {
                right_pop_menu.visible = true
                if (mouseX >= player_widget.width - right_pop_menu.width)
                    right_pop_menu.x = player_widget.width - right_pop_menu.width
                else
                    right_pop_menu.x = mouseX

                if (mouseY >= player_widget.height - right_pop_menu.height)
                    right_pop_menu.y = player_widget.height - right_pop_menu.height
                else
                    right_pop_menu.y = mouseY
            } else {
                right_pop_menu.visible = false
            }
        }
    }

    ListModel {
        id: right_pop_menu_context
        ListElement {
            name: "prev media"
        }
        ListElement {
            name: "next media"
        }
        ListElement {
            name: "setting"
        }
        ListElement {
            name: "close"
        }
    }

    PopMenu {
        id: right_pop_menu
        element_height: 20
        pop_menu_model: right_pop_menu_context
        visible: false
        context_count: right_pop_menu_context.count
    }
}
